288 PART 5 Looking for Relationships with Correlation and Regression

It would be easier to answer those questions if you had a curve that represented

the data without all the random fluctuations of the individual points. How would

you go about fitting such a curve to these data? LOWESS to the rescue!

Running LOWESS regression in R is similar to other regression. You need to tell R

which variable represents x and which one represents y, and it does the rest. If

your variables in R are actually named x and y, the R instruction to run a LOWESS

regression is the following: lowess(x y f

, ,

.

0 2). (We explain the

.

f

0 2 part in the

following section.)

Unlike other forms of regression, LOWESS doesn’t produce a coefficients table.

The only output is a table of smoothed y values, one for each data point, which you

can save as a data file. Next, using other R commands, you can plot the x and y

points from your data, and add a smoothed line superimposed on the scatter graph

based on the smoothed y values. Figure 19-11 shows this plot.

In Figure 19-11, the smoothed curve seems to fit the data quite well across all ages

except the lower ones. The individual data points don’t show any noticeable

upward trend until age 12 or so, but the smoothed curve starts climbing right

from age 3. The curve completes its rise by age 20, and then remains flat until

almost age 50, when it starts declining. The rate of decline seems to be greatest

between ages 50 to 65, after which it declines less rapidly. These subtleties would

be very difficult to spot just by looking at the individual data points without any

smoothed curve.

FIGURE 19-11:

The fitted

LOWESS curve

follows the shape

of the data,

whatever it

may be.

© John Wiley & Sons, Inc.